<?php

namespace app\api\controller;

use app\api\logic\ReconciliationLogic;
use think\facade\Db;

class ReconciliationPackage
{
    /**
     * @desc  顺丰对账
     */
    public function reconciliation_sf(){
        $t1       = microtime(true);
        $count = Db::name('checkbill_sf')->where('reconciliation_status',0)->count();
        $pageSize = 500; // 每500条记录读取一次
        $page     = ceil($count / $pageSize);
        $executedCount = 0;
        for ($i = 1; $i <= $page; $i++){
            $list = Db::name('checkbill_sf')
                ->where('reconciliation_status',0)
                ->paginate($pageSize)
                ->toArray();
            foreach ($list['data'] as $k=>$v) {
                (new ReconciliationLogic())->reconciliation_sf($v);
                $executedCount++;
                $num = $count - $executedCount;
                echo PHP_EOL . "总计:" . $count . '条' . '-----' . "已执行:" . $executedCount . '-----' . '剩余:' . $num . '条' . PHP_EOL;
            }
        }
        echo PHP_EOL . "get_webhook_infos-定时执行总耗时:" . round(microtime(true) - $t1, 3) . PHP_EOL;
    }



}
